import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Injectable } from '@angular/core';
import { SheetListService } from '../sheet-list/sheet-list.service';
import { SheetQueryCriteria } from '../entity';

@Injectable()
export class SheetListResolve implements Resolve<any> {

  constructor(
    private sheetListService: SheetListService
  ) { }

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    const category = route.queryParamMap.get('category');
    const queryCriteria: SheetQueryCriteria = {
      limit: 35,
      offset: 1,
      cat: category,
      order: 'hot'
    };
    return this.sheetListService.getSheets(queryCriteria);
  }

}
